
Vue.component2('a_1_0_2_7_1', {  
    template: `
        <div :class="{ 'a_1_0_2_7_1_lines test': data.true, 'a_1_0_2_7_1_lines_onclick': data.onclick_flag }" @click="handle_click" v-show="show_flag">
        <span :style="'padding-left: '+data._space_+'px;'"></span>
        <span  v-if="data.icon1_show_flag":class="{'icon iconfont':data.true,'icon-right':data.close,'icon-down':data.close==false}"></span>
        
        <span  class="a_1_0_2_7_1_hid_line" style="color:#bcbcbc">{{data.name}}</span>
        <div style="display:inline-block;flex:1;">
        <div style="display:flex;
    justify-content: flex-end;
    display: flex;">
    
        <div  @click="click1($event,k)" v-for="(v,k) in data.icon_data"
        :key="k">
         <a_1_0_3_0_0 style="display: inline-block;"
         :deepcopy_data="v"></a_1_0_3_0_0>
        </div>
        </div>
        </div>
        </div>
`,
data(){
    return{
        show_flag:true,
        data:{
          onclick_flag:false,
            tree_data:{},//
            icon_data:{},
            icon1_show_flag:true,
            click:null,
            click_obj:null,
            true:true,
            false:false,
            close:true,
            name:"",
            _space_:0,
        }
    }
},
methods:{
  lhp_run_func:function(str_,obj=null,test=false){
      if (obj.includes(".")){
        try{

          let obj_t=window;
          let arr1= obj.split('.');  
          for (let i=0;i<arr1.length;i++){ obj_t=obj_t[arr1[i]]}
          obj=obj_t
        }catch(err){console.log("error:",err);
}
      }
      console.log("obj:",obj)
      if ((typeof str_) ==='function'){
          if (obj!=null){
              return str_(obj)
          }else{
              return str_()
          }
      }
      try{
          if (str_==''){return null;}
          else if (str_.includes('.')){
              let arr = str_.split('.');  
              let run_func=window
              for (let i=0;i<arr.length-1;i++){ run_func=run_func[arr[i]]}
              if (obj!=null){
                  if(test){console.log("lhp_run_func func params:",run_func[arr[arr.length-1]],obj)
}
                  return run_func[arr[arr.length-1]](obj)
              }else{
                  return run_func[arr[arr.length-1]]()
              }
          }else{
              if (obj!=null){
                  return window[str_](obj)
              }else{
                  return window[str_]()
              }
          }
          
    }catch(err){if(test){console.log("lhp_run_func err:",err);
}}
  },
    handle_click:async function(event){
      //点击当前 高亮显示
      try{console.log("高亮",this.data.path);
this.data.tree_data.set_onclick_flag(this.data.path)}catch{}
      //显示编辑界面
      try{
        console.log("this.data.tree_data.选择流程_onclick",this.data.tree_data.选择流程_onclick)
        for(let ii=0;ii<this.data.tree_data.选择流程_onclick.length;ii++){
          let ccc=this.data.tree_data.选择流程_onclick[ii];
          /*console.log("cc",ccc,ccc.func)*/
          await lhp_run_func2(ccc.func,this.data.path);
      }
        
      }catch (err){console.log("errrr:",err);
}
        // /* console.log("我点击了一次")*/
        try{
            if(!this.data.tree_data.check_dct[this.data.path]){
                await this.data.刷新目录1();
            }
            /*console.log("?2")*/}
        catch{}

        if (this.data.click){
            try{
                this.data.click(event)
            
                // console.log("start click2")
            }
            catch{}
            return 
        }




        if (this.data.click_obj){
          try{
            this.lhp_run_func(this.data.click_obj.func,this.data.click_obj.args);
          }
          catch{}
          return 
      }
        try{
            this.data.click_handle(this.data.path,this.data.close);
        }catch{}
    },
    click1:async function(event,k){
       /* console.log(',,,',this.data.icon_data[k].click)*/
        lhp_run_func(this.data.icon_data[k].click);
        if(!this.data.click_stop){event.stopPropagation();}//阻止父级

    }
},

mounted:function(){
    let tree_data=_this.deepcopy_data.tree_data;
    _this.data.全局配置对象=tree_data['全局配置对象'];
    _this.data.change_name=function(name){
        
        if(!_this.data.flow_id){_this.data.flow_id=_this.data.path.split(".")[_this.data.path.split(".").length-1]}
    //更新数据 
    
    //更新数据 
    let update_val={
        "type":"change_data",
        "data_type":"set_list",//类型 修改数据
        "postput":[{
            'path':`flow_chat_config.dict.1.dict.${_this.data.flow_id}.base_info.deepcopy_data`,
            'data':{"name":name}
          },
        
        ],
      }
    //向服务端websocket发送消息
    _this.data.全局配置对象.更新(update_val);
    }
    _this.data.del=function(){
        if(!_this.data.flow_id){_this.data.flow_id=_this.data.path.split(".")[_this.data.path.split(".").length-1]}
        //更新数据 
        let update_val={
            "type":"change_data",
            "data_type":"set_list",//类型 修改数据
            "delete":[{
                'path':`flow_chat_config.dict.1.dict.${_this.data.flow_id}`,
              },
            ],
          }
        //向服务端websocket发送消息
        _this.data.全局配置对象.更新(update_val);
        }
_this.data.icon_data={
    90:{
        icon_class:"icon iconfont icon-write",
        hovertext:"修改属性",
        add_show:false,
        click:async function(){
        _this.$prompt('修改名称', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
          }).then(({ value }) => {
            try{_this.data.change_name(value);}
            catch (err){
                console.log("出错..",err)
            }
            
          }).catch(() => {
            _this.$message({
              type: 'info',
              message: '取消输入'
            });       
          });
        }
        },
    100:{
        icon_class:"icon iconfont icon-shanchu",
        hovertext:"删除该流程",
        add_show:false,
        click:async function(){
        
        
            _this.$confirm('此操作将删除, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(() => {
                _this.data.del();
    
              
              }).catch(() => {
                _this.$message({
                  type: 'info',
                  message: '已取消删除'
                });          
              });



        }
        },
}


}

})